AddCSLuaFile("autorun/register.lua")
print("#########################");
print("##Gameweb Hooks Loaded###");
print("#########################");
resource.AddFile("sound/gameweb/welcome.mp3");
require( "mysql" )
local host = "127.0.0.1"
local username = ""
local password = ""
local db = "gmod_tools"
function Reg(ply)
	timer.Create("Steam_id_delay", 1, 1, function()	
			local db, error = mysql.connect(host, username, password, db)   
			if (db == 0) then print(tostring(error) .. "\n") return end  
				SID = mysql.query(db, "SELECT count(*) FROM users WHERE SteamID = '".. ply:SteamID().."'");
				Nick =  mysql.query(db, "SELECT Nick FROM users WHERE Nick = '".. ply:Nick() .."'");
				if (not succ) then
					print( error );
				end
				if tonumber(SID[1][1]) != 1 then
					ply:ConCommand("register",ply,"fgfdghfgkuilu")
					ply:SetNWString("Title","Guest")
				else
				if Nick[1][1] != ply:Nick() then
					Insert = mysql.query(db, "UPDATE users SET Nick='".. ply:Nick() .."' WHERE SteamID = '".. ply:SteamID() .."'");
				ply:SetNWString("Title",GamewebTitle(ply))
				end
				local succ, error = mysql.disconnect(db)
			end
	end)
end

hook.Add( "PlayerInitialSpawn", "Register", Reg )